<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>客户管理</title>
    <script src="http://localhost:10000/js/jquery-1.11.3.min.js"></script>
<!--   <script type="text/javascript" src="http://localhost:10000/js/tr1.js"></script>-->
    <style>
    #td1{
        width: 90%;
    background: #EEFFC2;
    }
    </style>
</head>
<body>


<table >
    <tr>
        <td>系统管理 >> 客户管理</td>
    </tr>
    <tr>
        <td>
            查询
        </td>
    </tr>
</table>
<form action="YongHu.do" >
    <table border="1" width=90% solid #505ca0>
        <tr><!--4行，11列 -->
            <td>
                客户id
            </td>
            <td colspan="10">
                <input type="text" id="custID" name="custID" th:value="${session.custID}" />
            </td>
        </tr>
        <tr>
            <td>
                客户名称
            </td>
            <td colspan="10">
                <input type="text" id="custName" name="custName" th:value="${session.custName}"/>
            </td>
        </tr>
        <tr>
            <td>
                IC卡号
            </td>
            <td colspan="10">
                <input type="text" id="custIc" name="custIc" th:value="${session.custIc}"/>
            </td>
        </tr>
        <tr><td colspan="11"><input type="submit" value="查询" ></td>
        <td><input type="hidden" th:value="${session.pageInfo.getPageNum()}" id="pageNum" name="pageNum"></td></tr>
    </table>
    每页显示条数<select name="pageSize" id="pageSize" onchange="lastpage1(this.value)">
    <option th:selected="${session.pageInfo.pageSize==15}">15</option>
    <option th:selected="${session.pageInfo.pageSize==10}">10</option>
    <option th:selected="${session.pageInfo.pageSize==5}">5</option>
</select>

</form>
<!--<iframe name="postTo" style="display:none"></iframe>-->
<table>
    <tr><td height="50px"></td></tr>
</table>
<label th:if="${session.pageInfo.size==0}" style="color: #ff4400">
    没有查到任何数据!请核对查询信息
</label>
<table border="1" width=90% th:if="${session.pageInfo.size!=0}">
    <tr>
        <td></td><td>客户ID</td><td>客户名</td><td>客户IC</td><td>IC硬件</td><td>固话</td><td>手机号</td><td>性别</td><td>编辑时间</td>
    </tr>
    <tr th:each="everyCus:${session.pageInfo.getList()}" id="tr1">
        <td><input type="radio" name="a" th:value="${everyCus.custID}" onclick="select1(this.value)"></td>
        <td th:text="${everyCus.custID}" ></td>
        <td th:text="${everyCus.custName}" ></td>
        <td th:text="${everyCus.custIc}" ></td>
        <td th:text="${everyCus.custIcChip}"></td>
        <td th:text="${everyCus.custTel}"></td>
        <td th:text="${everyCus.custMobile}"></td>
        <td th:text="${everyCus.custSex}"></td>
        <td th:text="${everyCus.custEditTime}"></td>
    </tr>
    <tr>
<!--        <label th:if="${session.pageInfo.getPageNum()==1 && session.pageInfo.getPages()>1}" style="color: #ff4400">-->
<!--            第一页了-->
<!--        </label>-->
        <button th:value="${session.pageInfo.getPageNum()>1?session.pageInfo.getPageNum()-1:session.pageInfo.getPageNum()}" onclick="lastpage(this.value)">上一页</button>
<!--        第<label th:text="${session.pageInfo.getPageNum()}"></label>页-->
        <input type="hidden" th:value="${session.pageInfo.getPageNum()}" id="pageNum" name="pageNum">
<!--        <button th:value="${session.pageInfo.isLastPage()==false?session.pageInfo.getPageNum()+1:session.pageInfo.getPageNum()}" onclick="lastpage(this.value)">下一页</button>-->
        <button th:value="${session.pageInfo.getPageNum()<session.pageInfo.getPages()?session.pageInfo.getPageNum()+1:session.pageInfo.getPageNum()}" onclick="lastpage(this.value)">下一页</button>
<!--        <label th:if="${session.pageInfo.getPageNum()==session.pageInfo.getLastPage()}" style="color: #ff4400">-->
<!--            最后一页了-->
<!--        </label>-->
    </tr>
</table>


    <table>
        <tr><td height="50px">客户信息</td></tr>
    </table>

    <form action="YongHu2.do" id="KH">
        <table border="1" width=90% ><!-- 11行11列-->
            <tr>
                <td>
                    货主编号
                </td>
                <td colspan="10">
                    <input type="text" id="custID1" readonly="readonly" name="custID"/>
                </td>
            </tr>

            <tr>
                <td>
                    货主名称
                </td>
                <td colspan="10">
                    <input type="text" id="custName1" name="custName" />
                </td>
            </tr>

            <tr>
                <td>
                    IC卡编号
                </td>
                <td colspan="10">
                    <input type="text" id="custIcChip1"  name="custIc" />
                </td>
            </tr>

            <tr>
                <td>
                    固定电话
                </td>
                <td colspan="10">
                    <input type="text" id="custTel1" readonly="readonly"/>
                </td>
            </tr>

            <tr>
                <td>
                    手机号码
                </td>
                <td colspan="10">
                    <input type="text" id="custMobile1"  name="custMobile" />
                </td>
            </tr>

            <tr>
                <td>
                    性别
                </td>
                <td colspan="10">
                    <input  type="text" id="custSex1" readonly="readonly"/>

                </td>
            </tr>

            <tr>
                <td>
                    备注
                </td>
                <td colspan="10" height="50px" width="200px">
                    <textarea rows="5" cols="40" id="custNote1" name="custNote"></textarea>
                </td>
            </tr>

            <tr>
                <td>
                    编辑时间
                </td>
                <td colspan="10">
                    <input type="text" id="custEditTime1" name="editTime" readonly="readonly"/>
                </td>
            </tr>

            <tr>
                <td>
                    状态
                </td>
                <td colspan="10">
                    <input id="state" type="radio"  name="state" value="1"/>删除
                    <input type="radio" name="state"checked="checked" value="0">活动
                </td>
            </tr>

            <tr>
                <td>

                </td>
                <td colspan="10">

                    <button type="submit">提交</button>
                    <button type="reset">重置</button>
                </td>
            </tr>
        </table>
    </form>
</body>
<script type="text/javascript">
    //上一页和下一页  86,96
    function lastpage(page) {
        var custName = $("#custName").val();
        var custIc = $("#custIc").val();
        var custID = $("#custID").val();
        var pageSize = $("#pageSize").val();
        window.location = "YongHu.do?pageNum="+page+"&pageSize="+pageSize+"&custName="+custName+"&custIc="+custIc+"&custID="+custID;
    }
    function lastpage1(pageSize) {
        var custName = $("#custName").val();
        var custIc = $("#custIc").val();
        var custID = $("#custID").val();
        var pageNum = $("#pageNum").val();
        window.location = "YongHu.do?pageNum="+pageNum+"&pageSize="+pageSize+"&custName="+custName+"&custIc="+custIc+"&custID="+custID;
    }
    //选择修改的客户信息，将查询到的值返回到客户信息列表
    function select1(custID) {
        $.ajax({
            url:"YongHu1.do",
            data:"custID="+custID,
            dataType:"json",
            success:function (data) {
                console.log(JSON.stringify(data)) ;
                for (var i = 0; i < data.length; i++){
                    $("#custID1").attr("value",data[i].custID);
                    $("#custName1").attr("value",data[i].custName);
                    $("#custIcChip1").attr("value",data[i].custIcChip);
                    $("#custTel1").attr("value",data[i]. custTel);
                    $("#custMobile1").attr("value",data[i].custMobile);
                    document.getElementById("custNote1").value=data[i].custNote;
                    // document.getElementById("custNote1").value="1";
                    $("#custSex1").attr("value",data[i].custSex);
                    $("#custEditTime1").attr("value",data[i].custEditTime);
                }
            }
        })
    }


</script>
</html>
